import { defineStore } from 'pinia'
import {getinfo} from '@/api/manager.js'
export const mainStore=defineStore('main',{
  state : () =>{
    return {
      user:[],
      menu:[],
      rule:[]
    }
  },
  getters:{},
  actions: {
    logout() {
      localStorage.removeItem('token')
      location.reload()
    },
    admin(){
    return new Promise((resolve,reject)=>{
      getinfo().then(res=>{
        this.user=res
        this.menu=res.menu
        this.rule=res.rule
        resolve(res)
      }).catch(err=>{
        reject(err)
      })
    })
    }
    },
  }
)